<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<link rel="stylesheet" href="$!rc.contextPath/common/common.css" />
		<link rel="stylesheet" href="$!rc.contextPath/css/info.css" />
		<link rel="stylesheet" href="$!rc.contextPath/common/dropload.css" />
		<title>参镜39度咨讯</title>
	</head>
	<body>
	<div class="title">
		<a href="http://app.tmaipay.com/">
		</a>
		<span>参镜39度咨讯</span>
	</div>	
	<!--头条-->
	<div class="con content">
		<div class="ad_list lists">
			
		</div>
	</div>
	</body>
	<script src="$!rc.contextPath/common/jquery-1.8.3.min.js"></script>
	<script src="$!rc.contextPath/common/dropload.min.js"></script>
	<script type="text/javascript">
	$(function(){
		f_init();
	});
	
	function f_init(){
		$(".lists").empty();
		$(".dropload-down").remove();
		
		var counter = 0;
	    // 每页展示4个
	    var num = 5;
	    var pageStart = 0,pageEnd = 0;
	
	    // dropload
	    $('.content').dropload({
	        scrollArea : window,
	        domUp : {
	            domClass   : 'dropload-up',
	            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
	            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
	        },
	        domDown : {
	            domClass   : 'dropload-down',
	            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
	            domNoData  : '<div class="dropload-noData">~没有更多资讯了~</div>'
	        },
	        loadDownFn : function(me){
	            $.ajax({
	                type: 'POST',
	                url: '$!rc.contextPath/common/infoList',
	                data : {
	                	startIndex : pageStart,
	                	pageSize : num
	                },
	                dataType: 'json',
	                success: function(data){
	                    var result = '';
	                    counter++;
	                    pageEnd = num * counter;
	                    pageStart += num;
	                    if(data.code == '0'){
	                    	var list = data.data;
	                    	console.log(list);
	                    	for(var i = 0; i < list.length; i++){
		                        result += '<div class="ad" onclick="f_detail(' + list[i].headlines_info_id + ')"><div class="left"><div>' + list[i].headlines_title + '</div><div class="agree"><span>' + list[i].add_time + '</span>' + 
		                        			'</div></div><img src="http://app.tmaipay.com/' + list[i].hd_img_one + '" /></div>';
		                        
	                    	}
	                    	
	                    	if(list.length < 5){
	                            // 再往下已经没有数据
	                            // 锁定
	                            me.lock();
	                            // 显示无数据
	                            me.noData();
	                            //break;
	                        }
	                    }
	
                        $('.lists').append(result);
                        // 每次数据加载完，必须重置
                        me.resetload();
	                },
	                error: function(xhr, type){
	                    alert('网络故障!');
	                    // 即使加载出错，也得重置
	                    me.resetload();
	                }
	            });
	        },
	        threshold : 50
	    });
	}
	
	function f_detail(infoId){
		window.location.href = '$!rc.contextPath/infoDetail?infoId=' + infoId;
	}
	</script>
</html>
